<template >
  <!-- <div v-if="state">123</div> -->
  <div v-if="!searchItemState">
    <SearchItem v-if="state" :position="position" />
  </div>
</template>

<script>
import SearchItem from "./SearchItem.vue";
export default {
  components: {
    SearchItem,
  },
  data() {
    return {
      position: [],
      searchItemState: true,
      thisState: false,
    };
  },
  methods: {
    setSearch(path) {
      if (path === this.addList) {
        this.searchItemState = false;
      } else if (path === this.addAfterSale) {
        this.searchItemState = true;
      } else {
        this.searchItemState = true;
      }
      this.$emit("setState", this.searchItemState, this.thisState);
    },
  },
  props: {
    state: Boolean,
    addList: String,
    addAfterSale: String,
  },
  watch: {
    $route(to) {
      // console.log(to.path);
      // console.log(this.addList);
      this.setSearch(to.path);
      // this.$emit(
      //   "setState",
      //   this.searchItemState,
      //   this.searchState,
      //   this.thisState
      // );
    },
  },
};
</script>

<style>
</style>